/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package plum.impl;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import plum.Decision;
import plum.PlumPackage;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Decision</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link plum.impl.DecisionImpl#getClonedFrom <em>Cloned From</em>}</li>
 *   <li>{@link plum.impl.DecisionImpl#getName <em>Name</em>}</li>
 *   <li>{@link plum.impl.DecisionImpl#getDescription <em>Description</em>}</li>
 *   <li>{@link plum.impl.DecisionImpl#isValidity <em>Validity</em>}</li>
 *   <li>{@link plum.impl.DecisionImpl#getId <em>Id</em>}</li>
 *   <li>{@link plum.impl.DecisionImpl#isClonable <em>Clonable</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class DecisionImpl extends EObjectImpl implements Decision {
	/**
	 * The cached value of the '{@link #getClonedFrom() <em>Cloned From</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getClonedFrom()
	 * @generated
	 * @ordered
	 */
	protected Decision clonedFrom;

	/**
	 * The default value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected static final String NAME_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected String name = NAME_EDEFAULT;

	/**
	 * The default value of the '{@link #getDescription() <em>Description</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDescription()
	 * @generated
	 * @ordered
	 */
	protected static final String DESCRIPTION_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getDescription() <em>Description</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDescription()
	 * @generated
	 * @ordered
	 */
	protected String description = DESCRIPTION_EDEFAULT;

	/**
	 * The default value of the '{@link #isValidity() <em>Validity</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isValidity()
	 * @generated
	 * @ordered
	 */
	protected static final boolean VALIDITY_EDEFAULT = false;

	/**
	 * The cached value of the '{@link #isValidity() <em>Validity</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isValidity()
	 * @generated
	 * @ordered
	 */
	protected boolean validity = VALIDITY_EDEFAULT;

	/**
	 * The default value of the '{@link #getId() <em>Id</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getId()
	 * @generated
	 * @ordered
	 */
	protected static final String ID_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getId() <em>Id</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getId()
	 * @generated
	 * @ordered
	 */
	protected String id = ID_EDEFAULT;

	/**
	 * The default value of the '{@link #isClonable() <em>Clonable</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isClonable()
	 * @generated
	 * @ordered
	 */
	protected static final boolean CLONABLE_EDEFAULT = false;

	/**
	 * The cached value of the '{@link #isClonable() <em>Clonable</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #isClonable()
	 * @generated
	 * @ordered
	 */
	protected boolean clonable = CLONABLE_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected DecisionImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return PlumPackage.Literals.DECISION;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Decision getClonedFrom() {
		if (clonedFrom != null && clonedFrom.eIsProxy()) {
			InternalEObject oldClonedFrom = (InternalEObject)clonedFrom;
			clonedFrom = (Decision)eResolveProxy(oldClonedFrom);
			if (clonedFrom != oldClonedFrom) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, PlumPackage.DECISION__CLONED_FROM, oldClonedFrom, clonedFrom));
			}
		}
		return clonedFrom;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Decision basicGetClonedFrom() {
		return clonedFrom;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setClonedFrom(Decision newClonedFrom) {
		Decision oldClonedFrom = clonedFrom;
		clonedFrom = newClonedFrom;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, PlumPackage.DECISION__CLONED_FROM, oldClonedFrom, clonedFrom));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getName() {
		return name;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setName(String newName) {
		String oldName = name;
		name = newName;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, PlumPackage.DECISION__NAME, oldName, name));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getDescription() {
		return description;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setDescription(String newDescription) {
		String oldDescription = description;
		description = newDescription;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, PlumPackage.DECISION__DESCRIPTION, oldDescription, description));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean isValidity() {
		return validity;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setValidity(boolean newValidity) {
		boolean oldValidity = validity;
		validity = newValidity;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, PlumPackage.DECISION__VALIDITY, oldValidity, validity));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getId() {
		return id;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setId(String newId) {
		String oldId = id;
		id = newId;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, PlumPackage.DECISION__ID, oldId, id));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean isClonable() {
		return clonable;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setClonable(boolean newClonable) {
		boolean oldClonable = clonable;
		clonable = newClonable;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, PlumPackage.DECISION__CLONABLE, oldClonable, clonable));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case PlumPackage.DECISION__CLONED_FROM:
				if (resolve) return getClonedFrom();
				return basicGetClonedFrom();
			case PlumPackage.DECISION__NAME:
				return getName();
			case PlumPackage.DECISION__DESCRIPTION:
				return getDescription();
			case PlumPackage.DECISION__VALIDITY:
				return isValidity();
			case PlumPackage.DECISION__ID:
				return getId();
			case PlumPackage.DECISION__CLONABLE:
				return isClonable();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case PlumPackage.DECISION__CLONED_FROM:
				setClonedFrom((Decision)newValue);
				return;
			case PlumPackage.DECISION__NAME:
				setName((String)newValue);
				return;
			case PlumPackage.DECISION__DESCRIPTION:
				setDescription((String)newValue);
				return;
			case PlumPackage.DECISION__VALIDITY:
				setValidity((Boolean)newValue);
				return;
			case PlumPackage.DECISION__ID:
				setId((String)newValue);
				return;
			case PlumPackage.DECISION__CLONABLE:
				setClonable((Boolean)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case PlumPackage.DECISION__CLONED_FROM:
				setClonedFrom((Decision)null);
				return;
			case PlumPackage.DECISION__NAME:
				setName(NAME_EDEFAULT);
				return;
			case PlumPackage.DECISION__DESCRIPTION:
				setDescription(DESCRIPTION_EDEFAULT);
				return;
			case PlumPackage.DECISION__VALIDITY:
				setValidity(VALIDITY_EDEFAULT);
				return;
			case PlumPackage.DECISION__ID:
				setId(ID_EDEFAULT);
				return;
			case PlumPackage.DECISION__CLONABLE:
				setClonable(CLONABLE_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case PlumPackage.DECISION__CLONED_FROM:
				return clonedFrom != null;
			case PlumPackage.DECISION__NAME:
				return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
			case PlumPackage.DECISION__DESCRIPTION:
				return DESCRIPTION_EDEFAULT == null ? description != null : !DESCRIPTION_EDEFAULT.equals(description);
			case PlumPackage.DECISION__VALIDITY:
				return validity != VALIDITY_EDEFAULT;
			case PlumPackage.DECISION__ID:
				return ID_EDEFAULT == null ? id != null : !ID_EDEFAULT.equals(id);
			case PlumPackage.DECISION__CLONABLE:
				return clonable != CLONABLE_EDEFAULT;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (name: ");
		result.append(name);
		result.append(", description: ");
		result.append(description);
		result.append(", validity: ");
		result.append(validity);
		result.append(", id: ");
		result.append(id);
		result.append(", clonable: ");
		result.append(clonable);
		result.append(')');
		return result.toString();
	}

} //DecisionImpl
